Repository navigation
Conversation
Adds GitHub's issue dependency endpoints:
- GET/POST /repos/{owner}/{repo}/issues/{number}/dependencies/blocked_by
(POST body { issue_id }), DELETE .../blocked_by/{issue_id}
- GET /repos/{owner}/{repo}/issues/{number}/dependencies/blocking
Edges may cross repositories. Reads need issues read on the path issue and
lists omit related issues the caller cannot see; writes need issues write.
Unknown or invisible issues return 404; a self-reference, a duplicate edge,
a malformed id or more than 50 relationships return 422. Issue objects carry
issue_dependencies_summary (open counts plus totals).
Seeding edges and the issue_dependencies webhook are not included yet.
Closes #9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Br5cbz3i7Y5PaRdx3DUfXx
| timeline_url: `${repoUrl}/issues/${issue.number}/timeline`, | ||
| performed_via_github_app: null, | ||
| author_association: computeAuthorAssociation(store, issue.user_id, issue.repo_id), | ||
| issue_dependencies_summary: issueDependenciesSummary(issue, store), |
There was a problem hiding this comment.
🔴 issue_dependencies_summary leaks private-repo issue counts.
🤖 Fix with your agent
Fix this code review finding (aictrl-dev/github-emulator PR #12, packages/@emulators/github/src/helpers.ts:387-405):
Problem: issue_dependencies_summary leaks private-repo issue counts
Detail: formatIssue is the shared serializer for every issue-returning endpoint (get/list/search/webhooks) but takes no authUser, and issueDependenciesSummary counts ALL dependency edges with no caller-visibility filtering — while the new list endpoints in the same PR deliberately filter edges through canRead(). Any caller who can read a public issue gets issue_dependencies_summary exposing the count, open/closed split and existence of blocker issues living in private repos they cannot see. This directly contradicts the PR's own test ("omits related issues the caller cannot see from lists") and the emulator's stated rule that private repos are invisible (404). Repro: given an octocat/alpha issue A and a private hubot/secret issue S with edge {blocked: A, blocking: S}, octocat's GET .../dependencies/blocked_by returns [] but GET /repos/octocat/alpha/issues/{A.number} returns issue_dependencies_summary {blocked_by:1, total_blocked_by:1} — octocat learns A is blocked by exactly one open issue inside a private repo. All three review agents (Security, Consistency, Bug Hunter) independently flagged this.
Suggested fix: Thread the requesting user into issue serialization (e.g. an optional authUser/visibility-predicate param on formatIssue, mirroring how formatRepo handles viewer permissions) and count only edges whose far-end issue lives in a repo the caller can read — the same canRead() check the list endpoints use. Alternatively compute the summary only inside the dependency routes where the caller is known, leaving the shared formatIssue payload unchanged. At minimum the summary must be consistent with the filtered GET .../dependencies/blocked_by response.
Implement the fix on the PR head branch and add a regression test that fails before the fix and passes after.
Why this matters
formatIssue is the shared serializer for every issue-returning endpoint (get/list/search/webhooks) but takes no authUser, and issueDependenciesSummary counts ALL dependency edges with no caller-visibility filtering — while the new list endpoints in the same PR deliberately filter edges through canRead(). Any caller who can read a public issue gets issue_dependencies_summary exposing the count, open/closed split and existence of blocker issues living in private repos they cannot see. This directly contradicts the PR's own test ("omits related issues the caller cannot see from lists") and the emulator's stated rule that private repos are invisible (404). Repro: given an octocat/alpha issue A and a private hubot/secret issue S with edge {blocked: A, blocking: S}, octocat's GET .../dependencies/blocked_by returns [] but GET /repos/octocat/alpha/issues/{A.number} returns issue_dependencies_summary {blocked_by:1, total_blocked_by:1} — octocat learns A is blocked by exactly one open issue inside a private repo. All three review agents (Security, Consistency, Bug Hunter) independently flagged this.
author_association: computeAuthorAssociation(store, issue.user_id, issue.repo_id),
issue_dependencies_summary: issueDependenciesSummary(issue, store),
};
}
/** Counts as GitHub reports them: `blocked_by` and `blocking` count open issues, the totals count all. */
function issueDependenciesSummary(issue: GitHubIssue, store: GitHubStore) {
const blockers = store.issueDependencies
.findBy("blocked_issue_id", issue.id)
.map((edge) => store.issues.get(edge.blocking_issue_id))
.filter((other): other is GitHubIssue => !!other);
const blocked = store.issueDependencies
.findBy("blocking_issue_id", issue.id)|
|
||
| app.delete("/repos/:owner/:repo/issues/:issue_number/dependencies/blocked_by/:issue_id", (c) => { | ||
| const { issue } = pathIssue(gh, c, "write"); | ||
| const blocking = issueById(gh, c.get("authUser"), c.req.param("issue_id")); |
There was a problem hiding this comment.
🟡 DELETE 404s when far-end issue becomes unreadable.
| const blocking = issueById(gh, c.get("authUser"), c.req.param("issue_id")); | |
| For DELETE, resolve the edge without the canRead gate: look the far issue up with a visibility-free gh.issues.get(id) (still 422/404 on a malformed or unknown id), authorize on write access to the PATH repo's issue, and 404 only if the edge itself doesn't exist. |
🤖 Fix with your agent
Fix this code review finding (aictrl-dev/github-emulator PR #12, packages/@emulators/github/src/routes/issue-dependencies.ts:94-98):
Problem: DELETE 404s when far-end issue becomes unreadable
Detail: DELETE resolves the far end via issueById, which returns 404 unless the caller can currently READ the blocking issue's repo. If that repo later becomes private or the caller's read access is revoked, a user with write access on the path repo can no longer remove an existing edge — the dependency becomes undeletable through the API even though removal should only require write on the blocked issue. POST only needed read at creation time, so the two endpoints are inconsistent about the far end. Repro: Given octocat can read hubot/secret and write octocat/alpha, and creates edge alpha#1 blocked_by secret#2 via POST; When hubot revokes octocat's read on hubot/secret; Then DELETE /repos/octocat/alpha/issues/1/dependencies/blocked_by/2 returns 404 instead of removing the edge, and the stale dependency can never be deleted via the API.
Suggested fix: For DELETE, resolve the edge without the canRead gate: look the far issue up with a visibility-free gh.issues.get(id) (still 422/404 on a malformed or unknown id), authorize on write access to the PATH repo's issue, and 404 only if the edge itself doesn't exist.
Implement the fix on the PR head branch and add a regression test that fails before the fix and passes after.
Why this matters
DELETE resolves the far end via issueById, which returns 404 unless the caller can currently READ the blocking issue's repo. If that repo later becomes private or the caller's read access is revoked, a user with write access on the path repo can no longer remove an existing edge — the dependency becomes undeletable through the API even though removal should only require write on the blocked issue. POST only needed read at creation time, so the two endpoints are inconsistent about the far end. Repro: Given octocat can read hubot/secret and write octocat/alpha, and creates edge alpha#1 blocked_by secret#2 via POST; When hubot revokes octocat's read on hubot/secret; Then DELETE /repos/octocat/alpha/issues/1/dependencies/blocked_by/2 returns 404 instead of removing the edge, and the stale dependency can never be deleted via the API.
app.delete("/repos/:owner/:repo/issues/:issue_number/dependencies/blocked_by/:issue_id", (c) => {
const { issue } = pathIssue(gh, c, "write");
const blocking = issueById(gh, c.get("authUser"), c.req.param("issue_id"));
const edge = gh.issueDependencies
.findBy("blocked_issue_id", issue.id)
.find((candidate) => candidate.blocking_issue_id === blocking.id);
if (!edge) throw notFoundResponse();| app.post("/repos/:owner/:repo/issues/:issue_number/dependencies/blocked_by", async (c) => { | ||
| const { issue } = pathIssue(gh, c, "write"); | ||
| const body = (await parseJsonBody(c)) as { issue_id?: unknown }; | ||
| const blocking = issueById(gh, c.get("authUser"), body.issue_id); |
There was a problem hiding this comment.
🟡 Read-only far end lets writers publish private issue links.
| const blocking = issueById(gh, c.get("authUser"), body.issue_id); | |
| Either fix the disclosure at the source by filtering issue_dependencies_summary per caller (see the helpers.ts finding), or additionally require the caller to hold write/push permission on the far-end repo when the edge crosses repositories, so private issues cannot be linked into publicly readable issues. |
🤖 Fix with your agent
Fix this code review finding (aictrl-dev/github-emulator PR #12, packages/@emulators/github/src/routes/issue-dependencies.ts:78-88):
Problem: Read-only far end lets writers publish private issue links
Detail: POST requires write only on the path repo and merely READ on the blocking issue's repo, so anyone with write on a public repo can attach an issue from a private repo they can only read as a blocker of a publicly readable issue. Combined with the unfiltered issue_dependencies_summary (flagged separately), this makes the writer the injection vector that publishes the existence and count of private-repo issues to every reader of the public repo. Even once the summary is caller-filtered, the linkage itself deserves a deliberate decision: either filter the summary per caller (preferred) or require stronger permission on the far-end repo for cross-repo edges.
Suggested fix: Either fix the disclosure at the source by filtering issue_dependencies_summary per caller (see the helpers.ts finding), or additionally require the caller to hold write/push permission on the far-end repo when the edge crosses repositories, so private issues cannot be linked into publicly readable issues.
Implement the fix on the PR head branch and add a regression test that fails before the fix and passes after.
Why this matters
POST requires write only on the path repo and merely READ on the blocking issue's repo, so anyone with write on a public repo can attach an issue from a private repo they can only read as a blocker of a publicly readable issue. Combined with the unfiltered issue_dependencies_summary (flagged separately), this makes the writer the injection vector that publishes the existence and count of private-repo issues to every reader of the public repo. Even once the summary is caller-filtered, the linkage itself deserves a deliberate decision: either filter the summary per caller (preferred) or require stronger permission on the far-end repo for cross-repo edges.
app.post("/repos/:owner/:repo/issues/:issue_number/dependencies/blocked_by", async (c) => {
const { issue } = pathIssue(gh, c, "write");
const body = (await parseJsonBody(c)) as { issue_id?: unknown };
const blocking = issueById(gh, c.get("authUser"), body.issue_id);
if (blocking.id === issue.id) throw new ApiError(422, "Validation failed");| if (!repo.has_issues) throw notFoundResponse(); | ||
| const issueNumber = Number(c.req.param("issue_number")); | ||
| if (!Number.isInteger(issueNumber)) throw notFoundResponse(); | ||
| const issue = gh.issues.findBy("repo_id", repo.id).find((i) => i.number === issueNumber && !i.is_pull_request); |
There was a problem hiding this comment.
🟡 pathIssue re-implements issues.ts findIssueForRepo.
| const issue = gh.issues.findBy("repo_id", repo.id).find((i) => i.number === issueNumber && !i.is_pull_request); | |
| Export findIssueForRepo (or a shared lookupIssue) from src/helpers.ts next to lookupRepo and use it both in routes/issues.ts and in pathIssue here. |
🤖 Fix with your agent
Fix this code review finding (aictrl-dev/github-emulator PR #12, packages/@emulators/github/src/routes/issue-dependencies.ts:33):
Problem: pathIssue re-implements issues.ts findIssueForRepo
Detail: pathIssue inlines `gh.issues.findBy("repo_id", repo.id).find((i) => i.number === issueNumber && !i.is_pull_request)` — the same lookup rule as the findIssueForRepo helper used by routes/issues.ts. Two route modules now maintain identical issue-lookup logic; if the rule changes (e.g. pull-request filtering or number parsing), they will drift. helpers.ts already hosts the analogous shared lookupRepo.
Suggested fix: Export findIssueForRepo (or a shared lookupIssue) from src/helpers.ts next to lookupRepo and use it both in routes/issues.ts and in pathIssue here.
Implement the fix on the PR head branch and add a regression test that fails before the fix and passes after.
Why this matters
pathIssue inlines gh.issues.findBy("repo_id", repo.id).find((i) => i.number === issueNumber && !i.is_pull_request) — the same lookup rule as the findIssueForRepo helper used by routes/issues.ts. Two route modules now maintain identical issue-lookup logic; if the rule changes (e.g. pull-request filtering or number parsing), they will drift. helpers.ts already hosts the analogous shared lookupRepo.
const issueNumber = Number(c.req.param("issue_number"));
if (!Number.isInteger(issueNumber)) throw notFoundResponse();
const issue = gh.issues.findBy("repo_id", repo.id).find((i) => i.number === issueNumber && !i.is_pull_request);
if (!issue) throw notFoundResponse();
return { repo, issue };
}| ) { | ||
| throw new ApiError(422, "Validation failed"); | ||
| } | ||
| gh.issueDependencies.insert({ blocked_issue_id: issue.id, blocking_issue_id: blocking.id }); |
There was a problem hiding this comment.
🟡 Dependency mutations emit no webhooks or timeline events.
| gh.issueDependencies.insert({ blocked_issue_id: issue.id, blocking_issue_id: blocking.id }); | |
| Destructure `webhooks` from RouteContext and, on POST/DELETE, insert an issue event via the shared insertIssueEvent helper and dispatch the corresponding `issues` webhook, matching the pattern in routes/issues.ts (or document why dependency changes intentionally emit none). |
🤖 Fix with your agent
Fix this code review finding (aictrl-dev/github-emulator PR #12, packages/@emulators/github/src/routes/issue-dependencies.ts:88-89):
Problem: Dependency mutations emit no webhooks or timeline events
Detail: Every other mutating issue route in routes/issues.ts records an issue event (insertIssueEvent) and dispatches an `issues` webhook (opened/closed/assigned/...), but the new POST/DELETE dependency handlers destructures only { app, store, baseUrl } and do neither. Webhook subscribers and the issue timeline silently miss dependency changes, breaking the emulator's change-notification convention now that issue_dependencies_summary is part of every issue payload.
Suggested fix: Destructure `webhooks` from RouteContext and, on POST/DELETE, insert an issue event via the shared insertIssueEvent helper and dispatch the corresponding `issues` webhook, matching the pattern in routes/issues.ts (or document why dependency changes intentionally emit none).
Implement the fix on the PR head branch and add a regression test that fails before the fix and passes after.
Why this matters
Every other mutating issue route in routes/issues.ts records an issue event (insertIssueEvent) and dispatches an issues webhook (opened/closed/assigned/...), but the new POST/DELETE dependency handlers destructures only { app, store, baseUrl } and do neither. Webhook subscribers and the issue timeline silently miss dependency changes, breaking the emulator's change-notification convention now that issue_dependencies_summary is part of every issue payload.
if (
existing.length >= MAX_ISSUE_DEPENDENCIES ||
gh.issueDependencies.findBy("blocking_issue_id", blocking.id).length >= MAX_ISSUE_DEPENDENCIES
) {
throw new ApiError(422, "Validation failed");
}
gh.issueDependencies.insert({ blocked_issue_id: issue.id, blocking_issue_id: blocking.id });
return c.json(formatIssue(blocking, gh, baseUrl), 201);
});| .find((candidate) => candidate.blocking_issue_id === blocking.id); | ||
| if (!edge) throw notFoundResponse(); | ||
| gh.issueDependencies.delete(edge.id); | ||
| return c.json(formatIssue(blocking, gh, baseUrl)); |
There was a problem hiding this comment.
🟡 DELETE returns 200+body; GitHub contract is 204.
| return c.json(formatIssue(blocking, gh, baseUrl)); | |
| Return c.body(null, 204) from the DELETE handler (and update the test's expectations accordingly), matching GitHub's documented remove-dependency response and the sibling lock/unlock DELETE routes. |
🤖 Fix with your agent
Fix this code review finding (aictrl-dev/github-emulator PR #12, packages/@emulators/github/src/routes/issue-dependencies.ts:100):
Problem: DELETE returns 200+body; GitHub contract is 204
Detail: The DELETE dependency endpoint returns 200 with the full blocking-issue JSON body. GitHub's remove-issue-dependency contract responds 204 No Content on success, and the emulator's own destructive issue routes (e.g. DELETE /repos/:o/:r/issues/:n/lock) already follow the 204 convention. Clients written against GitHub's contract will parse this response differently than expected.
Suggested fix: Return c.body(null, 204) from the DELETE handler (and update the test's expectations accordingly), matching GitHub's documented remove-dependency response and the sibling lock/unlock DELETE routes.
Implement the fix on the PR head branch and add a regression test that fails before the fix and passes after.
Why this matters
The DELETE dependency endpoint returns 200 with the full blocking-issue JSON body. GitHub's remove-issue-dependency contract responds 204 No Content on success, and the emulator's own destructive issue routes (e.g. DELETE /repos/:o/:r/issues/:n/lock) already follow the 204 convention. Clients written against GitHub's contract will parse this response differently than expected.
if (!edge) throw notFoundResponse();
gh.issueDependencies.delete(edge.id);
return c.json(formatIssue(blocking, gh, baseUrl));
});
}
Code reviewVerdict: Do not merge — 1 blocker(s) must be fixed. · 🔴 1 · 🟠 0 · 🟡 5 · ⚪ 0 · 0/6 resolved
🤖 Fix all 6 open findings with your agent📋 Out-of-diff findings (6)
Reviewed 7 files · 0 inline · view all 6 findings ↗ · AI-generated — verify findings before acting · AI guidance and feedback aictrl · AI code review for fast-moving teams · aictrl.dev |
Dependencies (#12): - issue_dependencies_summary counts only related issues every reader of the issue can see (same repository or public), so the shared issue payload no longer reveals blockers in private repositories. - DELETE needs write on the blocked issue only, so an edge whose far end became unreadable can still be removed; a malformed id returns 400. - One findIssueForRepo helper for issue and dependency routes. Delivery IDs (#13): import randomUUID by name. Issue types (#14): formatIssueType lives in helpers.ts beside the issue serializer; a null issue_types seed means the defaults; the type resolver returns number | null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Br5cbz3i7Y5PaRdx3DUfXx
Review response — PR 12Fixes are in Issues addressed (pushed to this stack)
Review claims verified false (no change needed)
Not addressed here
|
Summary
Adds GitHub's issue dependency API, so a client that imports or syncs "blocked by" relationships can finish against the emulator (closes #9).
GET/POST /repos/{owner}/{repo}/issues/{number}/dependencies/blocked_by(POST body{ issue_id })DELETE /repos/{owner}/{repo}/issues/{number}/dependencies/blocked_by/{issue_id}GET /repos/{owner}/{repo}/issues/{number}/dependencies/blockingBehavior:
issuesread on the path issue. Lists omit related issues the caller cannot see.issueswrite. Unauthenticated writes get 401.per_page/pagewith aLinkheader.issue_dependencies_summary:blocked_byandblockingcount open issues, and the totals count all.Not included: seeding edges from config, and the
issue_dependencieswebhook. aictrl reads dependencies only.Stacked on #11; retarget to
github-onlyafter #11 merges.Verification
issue-dependencies.test.ts: 7 tests, covering both directions across repositories, open-only counts, 422 cases, 404 for unknown and invisible issues, filtering invisible issues out of lists, 401 for unauthenticated writes, and pagination plus the 50-relationship cap.node:24-bookworm-slim, all of these pass: build,type-check,type-check:tsc, lint (0 errors), format, smoke, and all package tests (core 113, github 187, github-emulator 6).job.done). A same-repo blocker becomes a task dependency. A cross-repo blocker exposed aictrl-dev/aictrl#7185.🤖 Generated with Claude Code
https://claude.ai/code/session_01Br5cbz3i7Y5PaRdx3DUfXx